<?php



namespace app\api\service\request;
use app\common\library\exception\ParameterException;
use app\common\library\HttpHeader;
use think\Log;
use think\Request;

/**
 * 检验app授权key
 *
 *
 *
 */
class CheckAppkey extends ApiCheck
{
    /**
     * 校验app key
     *
     *
     * @param Request $request
     * @return mixed|void
     * @throws ParameterException
     */
    public function doCheck(Request $request)
    {

        // 获取app key Map
        $appKeyMap = (array)$this->logicApi->getAppKeyMap('id,uid', 'id');
        if (!in_array($request->param("app_id"), $appKeyMap)) {
            throw new ParameterException([
                'msg'=>'Invalid Request.[ Auth Key No permission or nexistencet.]',
                'errorCode'=> 400003
            ]);
        }

        // //支付方式判断
        // $appCodeMap = (array)$this->logicPay->getAppCodeMap();
        // if (empty(self::get('payload')['channel']) ?: !in_array(self::get('payload')['channel'],$appCodeMap)) {
        //     throw new ParameterException([
        //         'msg'=>'Invalid Request.[ Payment Code Does Not Allowed.]',
        //         'errorCode'=> 400003
        //     ]);
        // }
    }
}
